<?php

/***  DOCUMENTATION LAYER

Last Update: Mar 2007
	
DESCRIPTION
	test array_lottery()
	
NOTES
	
***/

// Timer
$_tx0 = microtime();

// HEADER
echo "<h1 style='margin:8px 0 0;'>PHP Sandbox</h1>";
echo "<h4 style='margin:0 0 16px;'>array_lottery()</h4>";	// put script name here

// *** PROCEDURAL
if ( 0 ) 
{
	echo "<h4 style='margin:0; color:blue;'>Testing in Progess</h4>";
}


$_DIR['php'] = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR;
require_once($_DIR['php'] . 'array/array_lottery.inc.php');


// Test Function
if ( 1 )
{
	$run = 10;
	echo "<h2 style='margin:0; color:green;'>Function Test</h2>";	
	// each element represents the weighting factor of that candidate
	$CANDIDATE = array(50,25,12,9,3,1);
	echo "<h4 style='margin:4px 0 0'>Candidates (and their chances to win)</h4>"; print_r($CANDIDATE);
		
	while ( $run )
	{
		$WINNERS = array_lottery($CANDIDATE, 3);
		echo "<h6 style='margin:0; color:green;'>Winners</h4>"; print_r($WINNERS);
		echo "<h6 style='margin:0; color:#ccc;'>test #{$run} complete</h6>";
		$run--;
	}		
}

// Footer
$_txn = microtime();
$stx = number_format(((substr($_txn,0,9)) + (substr($_txn,-10)) - (substr($_tx0,0,9)) - (substr($_tx0,-10))),4); 
$footer = <<<HTML
<h4 style="margin:0; position:absolute; top:6px; right:6px; font-family:monospace; color:#36f; padding:4px; border:1px solid #36f; font-weight:normal; background:#f3f6ff;">
script completed in $stx s
</h4>
HTML;
echo $footer;

?>
